One. Traverse a map type1. Read the background Java program firstJava codeMapString,string>Paramvalues=New HashMapstring, string>();**** * * the intermediate assignment operation omitted***Data.put ("paramvalues", paramvalues); pass the value to velocity 2. Remove the key and value of this map from the foreground velocity template fileJava code#foreach ($param in ${paramvalues.keyset ()})Tr
Velocity (7) -- Advanced velocity usage and advanced velocity usage1. truncate part of the field substring
1 original string: $! Ag. tagValue, which may be very long, must be truncated when the front-end page is displayed. 2 # set ($ str = $! Ag. tagValue) 3 4 # if ($ str. length ()> 30) 5 # set ($ str = $ str. substring (0, 30) 6 $ str... 7 # else8 $! Ag. tagVal
forwarding.
This is a success?? The rest of the template looks almost the same as the previously familiar HTML file. Listing 5 shows the template for the application results page.
Listing 5. Velocity template for the resulting page
You can note that listing 5 does not include a JSP tag or a Struts tag. Let's take a look at it in detail:
(1) Use the link tool of strut
Velocity, velocity. js
Velocity is a java-based template engine that allows anyone to reference objects defined by java code simply using the template language. As a relatively complete template engine, Velocity has powerful functions, but it also increases application complexity.
I. Basic syntax
1. "#" is the sc
Basic use of velocity and basic use of velocity
Basic usage requirements of velocity: Master jstl Technology of jsp, because the usage of velocity is very similar to that of jstl. There is little difference in syntax, but the velocity example is obviously less than jstl, and
of available courses. Listing 9.1 shows the COURSELIST.VM, a velocity template that is equivalent to courselist.jsp for displaying a list of courses.Program Listing 9.1 Velocity-based course list#foreach ($course in $courses)${course.id}#end//Cycle through all coursesPerhaps the first thing you notice is that there are no template tags in this template. This is
Today, after you have upgraded some of the dependent jar versions to start a project, Some of the definitions in velocity in the COMMON.VM variables actually become null, did not include in the cause, and the environment is OK, after counter-check, and finally found that the Velocity-tools-beta1.jar upgrade to Velocity-tools.jar for ,
With velocity, many of the original tags are unusable and must be done with velocity tools, the latest version of Velocity Tools is 2.0, and here are some considerations for velocity tools:1. Integration issues with Spring MVC 3.x/4.xSpring 3.x/4.x only supports 1.3.x velocity
Use velocity tips and velocity tips
Due to the company's needs, I used the velocity template for file generation. Here are some tips for using the velocity template:
1. when intercepting a string, note that (1) Use. length () is used to obtain the string length. (2) it is best to replace "-1" in the form of "+ (-1)",
template file before writing the code according to the original process, temporarily forget the velocity. The code you write should be able to fully tune the content in one function that involves all levels of MVC. In this example, first write the Studentaction.java file, and the file shown in the WebApp directory. After writing the above code and running smoothly, we can write the template file according to the code we wrote earlier. Here, let's loo
Original address: http://www.ibm.com/developerworks/cn/java/j-lo-velocity1/ Velocity is a Java-based template engine that allows anyone to simply use the template language to refer to objects defined by Java code, thus separating the interface from the Java code so that the interface designer can synchronize with the Java Program developer to develop a we that follows the MVC architecture b site. But in the practical application,
Before using JSP development, you can easily get to the root project name through request, now change to use velocity rendering view, because it is not dependent on the environment of some classes such as Servlet,request, and the Web project's root project name is not written dead, need to get dynamically, At this time what to do, tried the online said a lot of ways, summed up the experience.The first type: (failure)
Configure the following i
Features of the table in HBaseBig: A table can be made up of tens of billions of rows, millions of columns (Riedo, insertion slows down)
Column-oriented: Column (family)-oriented storage and permission control, column (family) Independent retrievalSparse: For columns that are empty (null) and do not occupy storage space, the table can be designed to be very sparse.Multiple Versions: The data in each cell can be made up of multiple versions, and by default the version number is automatically ass
enough to prove that the velocity template engine is properly installed, and is enough to show the general process of separating the velocity template and how it behaves. Add the following line of code to the HELLOVELOCITY.VM template.
Hello $name, this is Velocity working!
Save the HELLOVELOCITY.VM template, and then create a new Hellovelocity.j
Basic Mode
When you use velocity in an application or a servlet, or anywhere else, it is usually handled as follows: Initialize velocity. Velocity can use two modes as a singleton mode for "separate runtime instances" (described in the following section), and you only need to initialize them once. Create a Context object (this is what is described later). Add you
application, the above Code is enough, from the code above, we can see that one advantage of velocity is that the template file can be developed in sync with the background file, as long as some common variable definitions are agreed, when the template is output, replace the variables by the template engine and then output the variables.
Example 2: velocity dynamic template creation and rendering (Java Pro
add {} When referencing a property
(3) Assignment of variables:
$name = "Hello"
The left side of the assignment must be a variable or a property reference. The right side can be one of the following six types:
Variable references, literal strings, property references, method references, literal numbers, array lists.
The following example shows each of these types:
#set ($monkey = $bill) # variable reference
#set ($monkey. Friend = "Monica") # # Strin
three points:
1. Keep the cache cluster running
2. monitor all cache hosts in the cache Cluster
3. Help cache hosts join cache Clusters
Cluster configuration storage Zone(Cluster configuration storage location)
Each time a cluster is started, the configuration information must be retrieved from the storage location in the cluster configuration. The following table shows two possible methods:
Powershell-based management tools(P
) Assignment of Variables : $name = "Hello"The left side of the assignment must be a variable or a property reference. The right side can be one of the following six types:Variable references , literal strings , property references , method references , literal numbers , array lists. The following example shows each of these types:#set ($monkey = $bill) # variable reference#set ($monkey. Friend = "Monica") # # String#set ($monkey. Blame = $whitehouse.
News has not only been published so far, but I have also published news that can generate static pages before. However, I always feel that it is not very professional and inefficient.
Apache velocity has been found. It can be used in many fields. Currently, it is only used to display pages in struts to avoid overload of the same URL (such as shownews. do, maybe n people watch the news at the same time. The detailed content of this news
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.